summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js/lib/view
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-08-31 22:37:03 +0200
committerJules Laplace <julescarbon@gmail.com>2020-08-31 22:37:03 +0200
commitd22d51a1ae49680015326857360eb699f31efced (patch)
tree43ac5007de26848f516b37b863daeb77f86d97d2 /StoneIsland/platforms/android/assets/www/js/lib/view
parenta81d20bc18d002623fc24cdcea8df7eed6d85bc9 (diff)
NO MORE ANDROID BUILD
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/view')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Router.js75
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js44
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js194
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/view/View.js147
4 files changed, 0 insertions, 460 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Router.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Router.js
deleted file mode 100755
index a8ec331f..00000000
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/Router.js
+++ /dev/null
@@ -1,75 +0,0 @@
-var Router = View.extend({
-
- routeByHash: false,
-
- go: function(url){
- this.parseRoute(url)
- },
-
- route: function(){
- var path = this.routeByHash ? window.location.hash.substr(0) : window.location.pathname
- path = path || "/"
- this.originalPath = path
- this.parseRoute(path)
- },
-
- parseRoute: function(pathname){
-
- pathname = pathname.replace(/^#/, "")
-
- if (pathname[0] !== "/") { pathname = "/" + pathname }
-
- var routes = this.routes,
- path = pathname.split("/");
-
- for (var i = 0; i < path.length; i++) {
- if (! path[i].length) {
- path[i] = null
- }
- }
-
- if (pathname in routes) {
- this[this.routes[pathname]]()
- return
- }
-
- if (path[path.length-1] == null) {
- path.pop()
- }
-
- for (var route in routes) {
- var routePath = route.split("/")
- if (routePath[1] == path[1]) {
- if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) {
- this[this.routes[route]](path[2])
- return
- }
- else if (routePath[2] == path[2]) {
- if (routePath[3] && path[3]) {
- if (routePath[3].indexOf(":") !== -1) {
- this[this.routes[route]](path[3])
- return
- }
- else if (routePath[3] == path[3]) {
- this[this.routes[route]]()
- return
- }
- }
- else if (! routePath[3] && ! path[3]) {
- this[this.routes[route]]()
- return
- }
- }
- else if (! routePath[2] && (! path[2].length || ! path[2])) {
- this[this.routes[route]]()
- return
- }
- }
- }
-
- if (is_mobile) {
- window.location.href = "/"
- }
- }
-
-})
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
deleted file mode 100755
index 7f90929a..00000000
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/Scrollable.js
+++ /dev/null
@@ -1,44 +0,0 @@
-var ScrollableView = View.extend({
-
- events: {
- "load img": "deferRefresh",
- },
-
- deferScrollToTop: function(){
- this.scrollPosition = 0
- setTimeout(this.scrollToTop.bind(this), 0)
- },
-
- scrollPosition: 0,
-
- resetScroll: function(){
- this.scrollPosition = 0
- },
-
- saveScroll: function(){
- this.scrollPosition = this.scroller.y
- },
-
- restoreScroll: function(){
- setTimeout(function(){
- this.scroller.scrollTo(0, this.scrollPosition)
- }.bind(this), 0)
- },
-
- refreshScroller: function(){
- this.scroller.refresh()
- clearTimeout( this.scrollerRefreshTimeout )
- },
-
- scrollerRefreshTimeout: null,
- deferRefresh: function(){
- clearTimeout( this.scrollerRefreshTimeout )
- this.scrollerRefreshTimeout = setTimeout(this.refreshScroller.bind(this))
- },
-
- scrollToTop: function(){
- this.scroller.refresh()
- this.scroller.scrollTo(0, 0)
- },
-
-}) \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
deleted file mode 100755
index 08802fa9..00000000
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js
+++ /dev/null
@@ -1,194 +0,0 @@
-var SerializableView = View.extend({
-
- events: {
- "change select": "update_select",
- "change [type=date]": "update_date",
- "focus input": "focus_input",
- "click .date-wrapper": "focus_date",
- "submit form": "save",
- },
-
- preload: function(data){
- if (! data && sdk.env == "production") { return }
- data = data || this.test_data
- if (! data) { return }
- this.load_data(data)
- },
-
- load_data: function(data){
- Object.keys(data).forEach(function(key){
- var value = data[key]
- var $el = this.$("[name=" + key + "]")
-
- if ($el.attr("type") == "checkbox") {
- $el.prop("checked", value)
- }
- if ($el.attr("type") == "date") {
- $el.val( value )
- this.update_date({ currentTarget: $el })
- }
- else if ($el.prop("tagName") == "SELECT") {
- $el.val( value )
- this.update_select({ currentTarget: $el })
- }
- else {
- $el.val( value )
- }
- }.bind(this))
- },
-
- serialize: function(){
- var fields = {}
- this.$("input[name], select[name], textarea[name]").each( function(){
- if (this.type == "checkbox") {
- if ($(this).prop("checked")) {
- fields[this.name] = this.value || "true"
- }
- }
- else {
- fields[this.name] = this.value
- }
- })
- return fields
- },
-
- deserialize: function(data){
- this.$("input[name], textarea[name]").val("")
- Object.keys(data).forEach(function(k){
- this.$("[" + k + "]").val(data[k])
- })
- },
-
- focus_input: function(e){
- $(e.currentTarget).removeClass("error_hilite")
- },
-
- focus_date: function(e){
- $(e.currentTarget).find("input").focus()
- },
-
- update_select: function(e){
- var $target = $(e.currentTarget), value = $target.val()
- var label = $target.find("option").filter(function(){ return this.value === value }).html()
- var $parent = $target.parent()
- $parent.addClass("picked").removeClass("error_hilite")
- $parent.find("span").html(label)
- },
-
- update_date: function(e){
- var $target = $(e.currentTarget), value = $target.val()
- var label = moment(value).format("MM/DD/YYYY")
- if (label === 'Invalid date') {
- label = '' // 'BIRTHDAY (OPTIONAL)'
- }
- $target.parent().addClass("picked")
- $target.parent().find("span").html(label)
- },
-
- validate: function(data, errors){
- var data = data || this.serialize()
- var errors = errors || []
- var presence_msgs = this.validate_presence || {}
- if (! this.disabled) {
- Object.keys(presence_msgs).forEach(function(k){
- if (! data[k]) errors.push( [ k, presence_msgs[k] ] )
- })
- }
- this.validate_fields && this.validate_fields(data, errors)
- this.cc && this.cc.validate(data, errors)
- this.address && this.address.validate(data, errors)
- return { errors: errors, data: data }
- },
-
- show_errors: function(errors){
- console.log("showing errors")
- console.log(errors)
- var msgs = []
- this.$('.err_heading').addClass('error_visible')
- this.$('.error_hilite').removeClass('error_hilite')
- this.$('.err').html('')
- errors.forEach(function(e, i){
- // if (i > 0) { return }
- if (e[0]) {
- var $el = this.$("[name=" + e[0] + "]")
- var el = $el[0]
- if (el && el.nodeName === 'SELECT') {
- $el.parent().addClass('error_hilite')
- $el.parent().next('.err').html(e[1])
- } else if (el && el.type === 'date') {
- $el.parent().addClass('error_hilite')
- $el.parent().next('.err').html(e[1])
- } else {
- $el.addClass('error_hilite')
- $el.next('.err').html(e[1])
- }
- }
- // msgs.push(e[1])
- }.bind(this))
- // this.$msg.html(msgs.join("<br>"))
- this.$msg.addClass('alert-notice')
- if (app.view.scroller) {
- app.view.scroller.scrollTo(0, 0)
- }
- },
-
- hide_errors: function(){
- this.$msg.removeClass('alert-notice')
- this.$msg.html("")
- },
-
- finalize: function(data){
- return data
- },
-
- save: function(e){
- e && e.preventDefault()
-
- this.$('.err_heading').removeClass('error_visible')
-
- var valid = this.validate()
- if (valid.errors.length) {
- this.show_errors(valid.errors)
- return
- }
- else {
- this.hide_errors()
- window.cordova && cordova.plugins.Keyboard.close()
- }
-
- var finalized_data = this.finalize(valid.data)
- this.submit( finalized_data )
- },
-
- submit: function(data){
- if (! data) {
- return
- }
- app.curtain.show("loading")
- this.action({
- data: data,
- success: function(data){
- app.curtain.hide("loading")
- this.success(data)
- }.bind(this),
- error: function(data){
- app.curtain.hide("loading")
- console.log("api error")
- this.error(data)
- }.bind(this),
- })
- },
-
- success: function(data){
- console.log("SUCCESS")
- console.log(data)
- },
-
- error: function(data){
- console.log("FAIL")
- console.log(data)
- },
-
-})
-
-var FormView = View.extend(SerializableView.prototype).extend(ScrollableView.prototype)
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/View.js b/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
deleted file mode 100755
index 2401df0d..00000000
--- a/StoneIsland/platforms/android/assets/www/js/lib/view/View.js
+++ /dev/null
@@ -1,147 +0,0 @@
-var View = (function($, _){
-
- var View = function(options) {
- this._id = _.uniqueId('view')
- this.type = "view"
- options || (options = {});
- _.extend(this, _.pick(options, viewOptions))
- this._ensureElement()
- this.initialize.apply(this, arguments)
- this.delegateEvents()
- }
-
- var delegateEventSplitter = /^(\S+)\s*(.*)$/;
-
- var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
-
- _.extend(View.prototype, {
-
- // The default `tagName` of a View's element is `"div"`.
- tagName: 'div',
-
- $: function(selector) {
- return this.$el.find(selector);
- },
-
- initialize: function(){},
-
- setElement: function(element, delegate) {
- if (this.$el) this.undelegateEvents();
- this.$el = element instanceof $ ? element : $(element);
- this.el = this.$el[0];
- if (delegate !== false) this.delegateEvents();
- return this;
- },
-
- // Set callbacks, where `this.events` is a hash of
- //
- // *{"event selector": "callback"}*
- //
- // {
- // 'mousedown .title': 'edit',
- // 'click .button': 'save',
- // 'click .open': function(e) { ... }
- // }
- //
- // pairs. Callbacks will be bound to the view, with `this` set properly.
- // Uses event delegation for efficiency.
- // Omitting the selector binds the event to `this.el`.
- // This only works for delegate-able events: not `focus`, `blur`, and
- // not `change`, `submit`, and `reset` in Internet Explorer.
- delegateEvents: function(events) {
- if (!(events || (events = _.result(this, 'events')))) return this;
- this.undelegateEvents();
- for (var key in events) {
- var method = events[key];
- if (!_.isFunction(method)) method = this[events[key]];
- if (!method) continue;
-
- var match = key.match(delegateEventSplitter);
- var eventName = match[1], selector = match[2];
- method = _.bind(method, this);
- if (is_mobile) {
- if (eventName === 'mouseenter' || eventName === 'mouseleave') {
- continue
- }
- if (is_android && eventName === 'click') {
- eventName = 'touchstart'
- }
- }
- eventName += '.delegateEvents' + this._id;
- if (selector === '') {
- this.$el.on(eventName, method);
- } else {
- this.$el.on(eventName, selector, method);
- }
- }
- return this;
- },
-
- // Clears all callbacks previously bound to the view with `delegateEvents`.
- undelegateEvents: function() {
- this.$el.off('.delegateEvents' + this._id);
- return this;
- },
-
- // Ensure that the View has a DOM element to render into.
- // If `this.el` is a string, pass it through `$()`, take the first
- // matching element, and re-assign it to `el`. Otherwise, create
- // an element from the `id`, `className` and `tagName` properties.
- _ensureElement: function() {
- this.setElement(_.result(this, 'el'), false);
- },
-
- preventDefault: function(e){
- e && e.preventDefault()
- },
-
- stopPropagation: function(e){
- e && e.stopPropagation()
- },
-
- });
-
-
- var extend = function(protoProps, staticProps) {
- var staticProps = staticProps || {}
- var parent = this;
- var child;
- var childEvents = {};
-
- // The constructor function for the new subclass is either defined by you
- // (the "constructor" property in your `extend` definition), or defaulted
- // by us to simply call the parent's constructor.
- if (protoProps && _.has(protoProps, 'constructor')) {
- child = protoProps.constructor;
- } else {
- child = function(){ return parent.apply(this, arguments); };
- }
-
- // Extend events so we can subclass views
- _.extend(childEvents, parent.prototype.events, protoProps.events)
-
- // Add static properties to the constructor function, if supplied.
- _.extend(child, parent, staticProps);
-
- // Set the prototype chain to inherit from `parent`, without calling
- // `parent`'s constructor function.
- var Surrogate = function(){ this.constructor = child; };
- Surrogate.prototype = parent.prototype;
- child.prototype = new Surrogate;
-
- // Add prototype properties (instance properties) to the subclass,
- // if supplied.
- if (protoProps) _.extend(child.prototype, protoProps);
-
- // Set a convenience property in case the parent's prototype is needed
- // later.
- child.prototype.__super__ = parent.prototype;
- child.prototype.events = childEvents
-
- return child;
- };
-
- View.extend = extend;
-
- return View;
-})(jQuery, _)