/* ========================================================================
 * ZUI: remote.js
 * http://zui.sexy
 * ========================================================================
 * Copyright (c) 2017-2018 cnezsoft.com; Licensed MIT
 * ======================================================================== */


(function($) {
    'use strict';

    var NAME = 'zui.remote'; // model name

    // The remote model class
    var remote = function(element, options) {
        var that = this;
        that.name = NAME;
        that.$ = $(element);

        options = that.options = $.extend({}, remote.DEFAULTS, this.$.data(), options);

        // Initialize here
    };

    // default options
    remote.DEFAULTS = {};

    // Extense jquery element
    $.fn.remote = function(option) {
        return this.each(function() {
            var $this = $(this);
            var data = $this.data(NAME);
            var options = typeof option == 'object' && option;

            if(!data) $this.data(NAME, (data = new remote(this, options)));

            if(typeof option == 'string') data[option]();
        });
    };

    remote.NAME = NAME;

    $.fn.remote.Constructor = remote;

    // Auto call remote after document load complete
    $(function() {
        $('[data-ride="remoteBox"]').remote();
    });
}(jQuery));

