Build a JavaScript-based mobile cms--add slide

Source: Internet
Author: User

After discussing with several small partners who are interested in doing mobile CMS , we feel that it is more important to unify the restful API at the moment. However, the recent interruption of the network, a power outage, suspended the thinking of the API. In the weekend bored time saw the "human lost lattice", and saw the will "a person wandering, do not have to go far." Start thinking about something other than technology, and perhaps it will be the subject of the next discussion.

While I am helpless the function of this mobile CMS, help the small partners to do a picture sliding, then think of this function added, very successfully found a library.

Mobile CMS Swipe

The two functions we need are simple

    1. When the user slides to the right, the menu should expand
    2. When the user slides to the left, the menu should be closed

I saw a simple example on the official website, but it wasn't for this menu, and I didn't know it until I finished it: why not use the menu?

Found a library that fits the functionality, although it's not hard to know what to write about. Compared to their own writing this library, it is better to use others to maintain a few times the library comes simple, stable.

jquery Plugin to obtain touch gestures from IPhone, IPod touch and IPad, should also work with Android mobile phones (not Tested yet!)

However, it does not work on some other devices.

Add jquery touchwipe

Add to Requirejs's configuration:

Require.config ({    baseUrl: ' lib/',    paths: {        jquery: ' jquery-2.1.1.min ',        router: '.. /router ',        touchwipe: ' Jquery.touchwipe.min '    },    shim: {        touchwipe: ["jquery"],        underscore: {            Exports: ' _ '}}    }); require (['.. /app '], function (APP) {    app.initialize ();});


(Note: The above code temporarily removes part of this article, for a brief description.) )

Next, add the following code to the App.js initialization method

$ (window). Touchwipe ({        wipeleft:function () {            $.sidr (' close ');        },        wiperight:function () {            $. Sidr (' open ');        },        preventdefaultevents:false    });

It becomes the code we need.

define ([' jquery ', ' underscore ', ' backbone ', ' router ', ' Jquerysidr ', ' touchwipe '], function ($, _, BACKBO                NE, Router) {var initialize = function () {$ (window). Touchwipe ({wipeleft:function () {            $.SIDR (' close ');            }, Wiperight:function () {$.SIDR (' open ');        }, Preventdefaultevents:false});            $ (document). Ready (function () {$ (' #sidr '). Show ();            $ (' #menu '). Sidr ();                    $ ("#sidr li a"). Bind (' Touchstart click ', function () {if (null! = Backbone.history.fragment) {                    _.each ($ ("#sidr li"), function (LI) {$ (LI). removeclass ()});                    $ (' a[href$= ' #/' +backbone.history.fragment+ ' "] '). Parent (). addclass (" active ");                    $.SIDR (' close ');                Window.scrollto (0,0);        }            });        });    Router.initialize ();    }; Return {initialize:initialize};}); 

We can achieve what we need.

    1. When the user slides to the right, the menu should expand
    2. When the user slides to the left, the menu should be closed
Other

In the Windows Phone's IE browser, however, the left and right slides are forward and backward, respectively.

CMS effect: Ink qi cms

QQ Discussion Group: 344271543

project:  https://github.com/gmszone/moqi.mobi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.